home *** CD-ROM | disk | FTP | other *** search
/ ftp.cs.arizona.edu / ftp.cs.arizona.edu.tar / ftp.cs.arizona.edu / icon / newsgrp / group97b.txt / 000119_icon-group-sender _Wed Nov 12 16:24:56 1997.msg < prev    next >
Internet Message Format  |  2000-09-20  |  2KB

  1. Return-Path: <icon-group-sender>
  2. Received: from kingfisher.CS.Arizona.EDU (kingfisher.CS.Arizona.EDU [192.12.69.239])
  3.     by baskerville.CS.Arizona.EDU (8.8.7/8.8.7) with SMTP id QAA07678
  4.     for <icon-group-addresses@baskerville.CS.Arizona.EDU>; Wed, 12 Nov 1997 16:24:56 -0700 (MST)
  5. Received: by kingfisher.CS.Arizona.EDU (5.65v4.0/1.1.8.2/08Nov94-0446PM)
  6.     id AA08248; Wed, 12 Nov 1997 16:24:55 -0700
  7. Sender: rpereda@ringer.cs.utsa.edu
  8. Message-Id: <346A07C2.4CAC@cs.utsa.edu>
  9. Date: Wed, 12 Nov 1997 13:47:14 -0600
  10. From: Ray Pereda <rpereda@ringer.cs.utsa.edu>
  11. X-Mailer: Mozilla 3.0 (X11; I; SunOS 5.5 sun4m)
  12. Mime-Version: 1.0
  13. To: Chris Lusena <lusena@cs.uky.edu>
  14. Cc: icon-group@optima.CS.Arizona.EDU
  15. Subject: Re: Regular Expressions
  16. References: <Pine.LNX.3.95.971110105527.10736A-100000@uther.cs.engr.uky.edu>
  17. Content-Type: text/plain; charset=us-ascii
  18. Content-Transfer-Encoding: 7bit
  19. Errors-To: icon-group-errors@optima.CS.Arizona.EDU
  20. Status: RO
  21.  
  22. Chris,
  23.  
  24. There is an excellent regular expression kit in the 
  25. Icon Programming Library written by Robert Alexander.
  26. Look for the file regexp.icn.  Here is an example that 
  27. extracts all the numbers from a text file:
  28.  
  29. link regexp
  30.  
  31. procedure main()
  32.  
  33.    text := ""
  34.    while text ||:= read()
  35.    num_pattern := "\\d+(\\.\\d+)?"
  36.  
  37.    text ? {
  38.       while tab(ReFind(num_pattern)) do {
  39.          number := tab(ReMatch(num_pattern))
  40.          write(number)
  41.       }
  42.    }
  43. end
  44.      
  45.  
  46.  
  47. -ray
  48.  
  49. Chris Lusena wrote:
  50. > For part of a class project I need/like to be able to find all
  51. > occanses of a Regular Expression in a ASCII file. Icon seams that is might
  52. > be good for this, since one can fine all occurance of a word easly.
  53. > So how would one go about this? I'd like to be able to serach for the Reg.
  54. > Exp. over line breaks if possable.
  55. > Thanks in advance foryou time and help.
  56. > --Chris Lusena                     U of Kentucky, Dept. of Com. Sci.
  57. > Just a plain boring .SIG, eh?      Lexington, Kentucky, U.S.A.
  58. > email: Lusena@cs.engr.uky.edu      #include<standard disclaimer>
  59. > and for the webbies out there:     http://www.cs.engr.uky.edu/~lusena/
  60.